// components/hotspotAd/hotspotAd.js
import {
  articleList
} from '../../api/article'
import util from '../../utils/util'
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },
  lifetimes:{
    attached(){
      this.loadHot()
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    images: []
  },

  /**
   * 组件的方法列表
   */
  methods: {
    loadHot() {
      articleList({
        articleType: 1,
        pageSize:12
      }).then(res => {
        res.data.data.forEach(item=>{
          item.thumbnail=util.thumbnail(item.thumbnail,186,130)
        })
        for (var i = 0; i < res.data.data.length; i += 3) {
          this.data.images.push( res.data.data.slice(i, i + 3));
        }
        this.setData({
          images:this.data.images
        })
      })
    },
    imgClick(e) {
      console.log(e)
      wx.navigateTo({
        url: '/pages/hotspot/hotspot/index?id='+e.currentTarget.dataset.item
      })  
    }
  }
})